package com.custom.topic;


import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;


@Component
public class TopicConsumer {

    private static AtomicInteger atomicInteger = new AtomicInteger(1);
    @RabbitListener(queues = "q1")
    public void receiveQ1(String hello,Message message) {
        String key = message.getMessageProperties().getReceivedRoutingKey();
        System.out.println(atomicInteger.getAndIncrement()+ " q1(*.orange.*)       接收到了： = [" + hello + "] routing key:" + key);

    }

    @RabbitListener(queues = "q2")
    public void receiveQ2(String hello,Message message) {
        String key = message.getMessageProperties().getReceivedRoutingKey();
        System.out.println(atomicInteger.getAndIncrement()+ " q2(*.*.rabbit,lazy.#)接收到了： = [" + hello+ "] routing key:" + key);

    }

}
